var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/functionalComponent/toolbar/bridge.ts
var bridge_exports = {};
__export(bridge_exports, {
  handleClick: () => handleClick
});
module.exports = __toCommonJS(bridge_exports);
var import_util = require("../../util");
async function handleBeforeClick(payload) {
  const { data, button: handleEvent, ...params } = payload;
  if (import_util.iup.isFunction(handleEvent.before)) {
    process.env.NODE_ENV === "development" && console.log(`before ${params.id}`, [params, data]);
    return await handleEvent.before({ ...params, data });
  }
  return;
}
async function handleAfterClick(payload) {
  const { data, button: handleEvent, ...params } = payload;
  if (import_util.iup.isFunction(handleEvent.after)) {
    process.env.NODE_ENV === "development" && console.log(`after ${params.id}`, [params, data]);
    return await handleEvent.after({ ...params, data });
  }
}
async function handleCurrentClick(payload) {
  const { params, onClick, data } = payload;
  let result;
  result = await (onClick == null ? void 0 : onClick({ ...params, data }));
  return result;
}
async function handleClick(payload) {
  const { onClick, getData, button, ...params } = payload;
  const data = getData ? await getData({ id: params.id }) : {};
  if (await handleBeforeClick({ ...params, data, button }) === false) {
    return;
  }
  const currentValue = await handleCurrentClick({ params, onClick, data });
  await handleAfterClick({ ...params, value: currentValue, data, button });
  return currentValue;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  handleClick
});
